import socket

s = socket.socket()

host = ''
port = 2000

s.bind((host,port))
s.listen(5)
connection,adress = s.accept()

if __name__ == '__main__':
    while True:
        request = connection.recv(1024)

        print(type(request)) # 'byte'

        print('ip and request,{}\n{}'.format(adress,request))

        # 必须加http头 不加浏览器显示不出来 \r\n\r\n http协议固定格式
        response = b'HTTP/1.1 200 OK\r\n\r\n<html><body>hello</body></html>'

        connection.send(response)


